<template>
    <div>
        <van-cell-group>
            <van-field v-model="weixin" placeholder="请输入微信号" />
        </van-cell-group>

       <van-button type="primary" style="display: block; margin: 30px auto; width: 90%;" @click="submit">确认修改</van-button>
         
    </div>
</template>

<script>
export default {
    name: 'editInfo',
    data() {
        return {
            weixin: '', //微信
        }
    },

    methods: {
        submit() {
            let params = {
                weixin: this.weixin, //微信
            };

            if (params.weixin === '') {
                this.$toast('请输入微信账号');
                return;
            }
            this.$http.post('/user/user/front/modifyUser', params).then(res => {
                if (res.status === 0) {
                    this.$store.dispatch('getUserInfo', this.$store.state.userInfo.token).then(() => {
                        this.$toast.success('修改成功');
                        setTimeout(() => {
                            this.$router.back();
                        }, 700)
                    })
                } else {
                    this.$toast.fail(res.messasge);
                }
            })
        }
    },

    created() {
        if (this.$route.query.weixin) {
            this.weixin = this.$route.query.weixin;
        }
    }
 
}
</script>

<style lang="scss">
.avatar {
    height: 40px;
    width: 40px;
    border-radius: 50%;
    img {
        height: 40px;
        width: 40px;
        border-radius: 50%;
    }
}
</style>
